package mutation;


import java.util.List;

import GA.Chromosome;
import Operations.Operation;
import Operations.ValuesGenerator;

public class DeleteRandomMethodCall extends MutationStrategy {

	@Override
	public Chromosome mutate( Chromosome individual) {
		List<Operation> ops= individual.getTest();
		try {
			if(ops.size()<3)return individual;
			int numOfMethods=ValuesGenerator.getRandomIntBetween(1, 10);
			for(int i=1;i<=numOfMethods && ops.size()>3;i++){
				int randPos = ValuesGenerator.getRandomInt(ops.size());
				ops.remove(randPos);
			}
			individual.setTest(ops);
			return individual;
		} catch (Throwable e){
			System.err.println("Insert Random Method Call Class:" + e.getMessage());
		}	

		
		return null;
		
	}

	@Override
	public boolean getMutationFlag() {
		return true;
	}
}

